package com.songlanyun.modules.order.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.songlanyun.modules.order.entity.Order;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.songlanyun.modules.order.model.vo.*;
import com.songlanyun.modules.ship.model.dto.BranchShipVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * 销售系统中的主订单
 *
 * @author lubo
 * @email sunlightcs@gmail.com
 * @date 2020-11-16 14:14:42
 */
@Mapper
public interface OrderDao extends BaseMapper<Order> {

    IPage<Order> userOrdersPage(IPage<Order> page, @Param("paramsMapToReq") OrderPageReq paramsMapToReq);

    IPage<Order> shopOrdersPage(IPage<Order> page, @Param("paramsMapToReq") OrderPageReq paramsMapToReq);

    Order loadByUserKey(@Param("userId") Long userId, @Param("orderId") Long orderId);

    Order loadByShopKey(@Param("shopId") Long shopId, @Param("orderId") Long orderId);

    UserOrderSlimStatisticsVo loadUserOrderSlimStatistics(@Param("shopId") Long shopId, @Param("userId") Long userId);

    List<OrderVO> exportList(@Param("paramsMapToReq") OrderPageReq paramsMapToReq);

    Integer loadOrderNumByTime(@Param("shopId") Long shopId, @Param("startTime") Long startTime, @Param("endTime") Long endTime);

    BigDecimal loadOrderAmountByTime(@Param("shopId") Long shopId, @Param("startTime") Long startTime, @Param("endTime") Long endTime);

    Integer loadWaitOperationNum(@Param("shopId") Long shopId, @Param("transactionStatus") Integer transactionStatus);

    IPage<Order> shopServiceOrderPage(IPage<Order> page, @Param("paramsMapToReq") OrderPageReq paramsMapToReq);

    List<BranchShipVO> exportWaitShip(@Param("paramsMapToReq") OrderPageReq paramsMapToReq);

    IPage<Order> areaOrdersPage(@Param("paramsMapToReq") IPage<Order> page, OrderPageReq paramsMapToReq);

    BigDecimal loadEquityStatistics(@Param("userId") Long userId);

    BigDecimal loadPlatformMonthEquity(@Param("startTime") Long startTime, @Param("endTime") Long endTime);

    BigDecimal loadActivatingOrderCount(@Param("userIds") List<Long> userIds);

    int allOrderCount(@Param("paramsMapToReq") OrderPageReq paramsMapToReq);

    List<Order> allOrderPage(@Param("paramsMapToReq") OrderPageReq paramsMapToReq);

    BigDecimal getCountTotalAmount(@Param("start") String firstDayOfLastMonth, @Param("end") String lastDayOfLastMonth);
}
